/*
 * OrderGoodsInfoView.java
 * business
 *
 * Created by ChenTao on 2017/2/21.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yidiandao.business.R;
import com.yidiandao.business.utils.ImageLoader;

/** 单个订单商品的View */
public class OrderGoodsInfoView extends LinearLayout {

    private ImageView mIvGoodsImage;
    private TextView mTvTitle;
    private TextView mTvSingelPrice;
    private TextView mTvCount;
    private TextView mTvStatus;

    public OrderGoodsInfoView(Context context) {
        this(context, null);
    }

    public OrderGoodsInfoView(Context context, AttributeSet attrs) {
        super(context, attrs);

        View root = LayoutInflater.from(context).inflate(R.layout.item_order_goods, this, true);

        mIvGoodsImage = (ImageView) root.findViewById(R.id.iv_goods_image);
        mTvTitle = (TextView) root.findViewById(R.id.tv_title);
        mTvSingelPrice = (TextView) root.findViewById(R.id.tv_singel_price);
        mTvCount = (TextView) root.findViewById(R.id.tv_count);
        mTvStatus = (TextView) root.findViewById(R.id.tv_status);
    }

    /** @param url 设置图片 */
    public void setImage(Context context, String url) {
        ImageLoader.loadImage(context, mIvGoodsImage, url);
    }

    /** @param name 商品名 */
    public void setName(String name) {
        mTvTitle.setText(name);
    }

    /** @param num 数量 */
    public void setCount(String num) {
        mTvCount.setText(num);
    }

    /** @param price 价格 */
    public void setPrice(String price) {
        mTvSingelPrice.setText(price);
    }

    /** @param status 状态 */
    public void setStatus(String status) {
        mTvStatus.setText(status);
    }
}
